﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;

namespace Nova_DAL
{
    public class TZoneDefine
    {
        string strSQL = "";
        DbHelper dbHelper = new DbHelper();
        DataSet ds = new DataSet();
        DbCommand cmd;
        int i = 0;

        /// <summary>
        /// 返回dataset
        /// </summary>
        /// <returns>ds</returns>
        ///Writer：[王成友]
        ///Create Date： [2010-7-5]
        public DataSet DataListTZoneDefine(int iLaneID)
        {
            try
            {
                cmd = dbHelper.GetStoredProcCommond("Sp_TZoneDefine");
                dbHelper.AddInParameter(cmd, "@LaneID", DbType.String, iLaneID);
                ds = dbHelper.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }


        /// <summary>
        /// 返回dataset
        /// 查找库区表信息
        /// </summary>
        /// <returns>ds</returns>
        ///Writer：[王成友]
        ///Create Date： [2010-7-6]
        public DataSet DLTZoneDefine()
        {
            try
            {
                strSQL = "select Zone_ID,PID,Zone_Name,IFDis,Structure,SubAreas,ShowColor FROM TBase_Zone order by PID ";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                ds = dbHelper.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }

        /// <summary>
        /// 返回string
        /// 查找库区表颜色
        /// </summary>
        /// <returns>ds</returns>
        ///Writer：[王成友]
        ///Create Date： [2010-7-6]
        public string getColor(string strZoneID)
        {
            string strColor = "";
            try
            {
                strSQL = "select ShowColor from TBase_Zone where Zone_ID ='" + strZoneID + "'";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                ds = dbHelper.ExecuteDataSet(cmd);
                strColor = ds.Tables[0].Rows[0]["ShowColor"].ToString();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strColor;
        }

        /// <summary>
        /// 成功与失败
        /// 修改库区类型
        /// </summary>
        /// <returns>ds</returns>
        ///Writer：[王成友]
        ///Create Date： [2010-7-7]
        public string UpdateZoneID(string iPID, int iZone_ID)
        {
            string strs = "";
            try
            {
                strSQL = "update TBase_Position set Zone_ID=@Zone_ID Where PID = @PID";
                cmd = dbHelper.GetSqlStringCommond(strSQL);
                dbHelper.AddInParameter(cmd, "@PID", DbType.String, iPID);
                dbHelper.AddInParameter(cmd, "@Zone_ID", DbType.Int32, iZone_ID);
                strs = dbHelper.ExecuteNonQuery(cmd).ToString();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strs;
        }
    }
}
